#!/bin/sh

#
# Test invoking fwup using the easy way
#

. "$(cd "$(dirname "$0")" && pwd)/common.sh"

cat >$CONFIG <<EOF
file-resource TEST {
        host-path = "${TESTFILE_150K}"
}

task complete {
	on-resource TEST { raw_write(1) }
}
EOF

# Create the firmware file, then "burn it"
$FWUP_CREATE -c -f $CONFIG -o $FWFILE

# The *easy* way -> Look, no -a or -i or -t
$FWUP_APPLY -d $IMGFILE $FWFILE
cmp_bytes 150000 $TESTFILE_150K $IMGFILE 0 512
rm $IMGFILE

# Switch the option order
$FWUP_APPLY $FWFILE -d $IMGFILE
cmp_bytes 150000 $TESTFILE_150K $IMGFILE 0 512
rm $IMGFILE

# Check that bunch of options still are "easy"
$FWUP_APPLY --eject -y -n $FWFILE -d $IMGFILE -u -t complete
cmp_bytes 150000 $TESTFILE_150K $IMGFILE 0 512
rm $IMGFILE

# Check that quiet works
$FWUP_APPLY -q $FWFILE -d $IMGFILE
cmp_bytes 150000 $TESTFILE_150K $IMGFILE 0 512
